import { PageDot } from '@/dto/page.dto'

export type TaskType = 0 | 1 | 2 | 3 | 4 | 5;
export type DataCalcType = 0 | 1 | 2 | 3 | 4;
export type DateTimeType = "second" | "minute" | "hour" | "day" | "month" | "year";
export type TimeType = "1" | "2" | "3" | "4" | "5";

/** 表类型 */
export enum IndicatorDataType {
  /** 实时 */
  Second = 0,
  /** 分钟 */
  Minute,
  /** 小时 */
  Hour,
  /** 天 */
  Day,
  /** 月 */
  Month,
  /** 年 */
  Year,
}

export const DataCalcTypeMap = {
  0: "SUM",
  1: "AVG",
  2: "MAX",
  3: "MIN",
  4: "FIR",
};

export const IndicatorDataMap = {
  second: IndicatorDataType.Second,
  minute: IndicatorDataType.Minute,
  hour: IndicatorDataType.Hour,
  day: IndicatorDataType.Day,
  month: IndicatorDataType.Month,
  year: IndicatorDataType.Year,
};

export class IndicatorDto {
  indicatorCode: string;
  dataTimeType: TaskType;
  dataCalcType: DataCalcType;
  formula: string;
  mergeType?: number;
  parentIndicatorCode?: string;
  parentId?: string;
}

export class GetIndicatorValueDto {
  indicatorCode: string;
  duration: number;
  dataTimeType: DateTimeType;
  dataCalcType: DataCalcType;
}

export class AddIndicatorDto {
  indicatorCode: string;
  indicatorName: string;
  indicatorDesc: string;
  sourceType: number;
  dataTimeType: number;
  dataType: number;
  formula: string;
  gatherCode: string;
  parentId: string;
  parentIndicatorCode: string;
  dataCalcType: number;
  dbSource: number;
  digit: number;
  maxVal: number;
  minVal: number;
  mergeType: number;
  isNull: string;
  isZero: string;
  sortId: number;
  unit: string;
  nodeGroupRelations?: any[];
  factoryId: string;
  orgId: string;
  appId: string;
  renterId: string;
}



export class GetIndicatorPageTreeDto {
  page: string;
  size: string;
  indicatorCode?: string;
  indicatorName?: number;
  indicatorDesc?: string;
  sourceType?: number;
  dataType?: number;
  tag?: string;
  factoryId?: string;
}

export class GetIndicatorPageDto {
  page: number;
  size: number;
  dataType?: number;
  indicatorOrName?: string;
  sourceType?: number;
  timeType?: number;
  factoryId?: number
  appId?: number
  orgId?: number
  renterId?: number
}

export class DeleteIndicatorDto {
  id: string;
  parentIndicatorCode?: string
}

export class GetIndicatorTagIndexListDto {
  indicatorCode: string;
  dataTimeType: string
  dataCalcType: string
  sourceType: string
}


export class CheckFormulaDto {
  formula: string;
  dataTimeType: TaskType;
  isNull: string;
}